import java.util.LinkedList;
import java.util.Set;


public class HeapSort {

	/**
	 * This method will take in a set of Comparable values that will then be sorted using a heap
	 * 
	 * @param set The set of type V elements to be heap sorted
	 * @return a LinkedList with the elements from the set parameter in sorted order
	 */
	public static <T extends Comparable<T>> LinkedList<T> heapSort(Set<T> set) {
		LinkedList<T> list = new LinkedList<T>();
		
		HeapInterface<T> minHeap = new MinHeap<T>();
		
		minHeap.addAll(set);
		
		for(int i=0; i<set.size(); i++){
			list.add(minHeap.remove());
		}
		
		return list;
	}
}
